﻿using Furion.DataEncryption;
using Furion.DynamicApiController;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication2;

[Authorize]
[ApiDescriptionSettings("test1")]
[Route("test1")]
public class Test1Controller : IDynamicApiController
{
    [AllowAnonymous]
    [HttpGet("login")]
    public object Login()
    {
        var accessToken = JWTEncryption.Encrypt(new Dictionary<string, object>()
            {
                { "UserId", "admin" },  
                { "Account","admin" },  
            });

        // 获取刷新 token
        var refreshToken = JWTEncryption.GenerateRefreshToken(accessToken, 43200); // 第二个参数是刷新 token 的有效期（分钟），默认三十天


        return new { accessToken, refreshToken };
    }

    [HttpGet("test")]
    public string Test()
    {
        return "ok";
    }
}